<?php

/**
 * Description of AdminMenu
 *
 * @author HaoLV
 */
Yii::import('application.modules.admin.models.Menu');

class AdminMenu extends CWidget {

    public $items = array('');

    public function run() {
        $this->items = ShortUtil::app()->cache->get('AdminMenu_' . ShortUtil::user()->id);
        $this->items = false;
        if ($this->items === false) {
            $items = Menu::model()->findAll('type_id=:type_id && parent_id=0 && status=1', array(':type_id' => 2));
            foreach ($items as $item)
                $this->items[] = $item->getList();

            ShortUtil::app()->cache->set('AdminMenu_' . ShortUtil::user()->id, $this->items, ConfigUtil::get('cache', 'time'));
        }

        $this->render('AdminMenu', array('items' => $this->items));
    }

}
